package com.atguigu.javase;

import com.atguigu.entities.Person;

/**
 * @Author: shenhao
 * @CreatTime: 2024/10/5 13:36
 * @Version: 1.0
 * Java是传值还是传引用  Java中就只有值传递  基本数值, 对象,内存地址的值
 * jvm虚拟机里面栈 方法的加载
 * 方法变量的作用域 Vector fork remote
 */
public class TransmitValueOrRef {
    public void changeValue1(int age){
        age = 30;
    }

    public void changeValue2(Person person){
        person.setName("new name");
    }
    public void changeValue3(String str){
        str = "new str";
    }

    public static void main(String[] args) {
        TransmitValueOrRef transmitValueOrRef = new TransmitValueOrRef();
        int age = 20;
        transmitValueOrRef.changeValue1(age);// 传值
        // 要求你打印出来的age到底是哪个方法的变量 栈管运行 堆管存储
        System.out.println("age = " + age);//20
        // 类模板 方法区 引用指针,在栈  实例对象,,在堆中
        Person person = new Person("shenhao");
        transmitValueOrRef.changeValue2(person);// 传地址的值, 引用
        System.out.println("person = " + person);
        //person = Person{name='new name'}

        String str = "hello world";
        transmitValueOrRef.changeValue3(str);
        System.out.println("str = " + str);//str = hello world
        /*Class<String> stringClass = String.class;
        Class<Integer> integerClass = Integer.class;*/
        Class<? extends TransmitValueOrRef> aClass = transmitValueOrRef.getClass();
    }
}
